package com.yunbiao.ybbusstopplate.refactoring.utils;

import android.util.Log;

import androidx.core.util.Consumer;

import com.blankj.utilcode.util.LogUtils;

public class L {

    private static Consumer<String> logConsumer;

    public static void setLogConsumer(Consumer<String> logConsumer) {
        L.logConsumer = logConsumer;
    }

    public static void d(String tag, String log){
        Log.d(tag, log);

        LogUtils.file(LogUtils.D,log);

        if(logConsumer != null){
            logConsumer.accept(log);
        }
    }

    public static void d(String tag, String msg, Throwable tr){
        Log.d(tag, msg, tr);

        LogUtils.file(LogUtils.D,msg,tr);

        if(logConsumer != null){
            logConsumer.accept(msg);
        }
    }

    public static void e(String tag, String msg){
        Log.e(tag, msg);

        LogUtils.file(LogUtils.E,msg);

        if(logConsumer != null){
            logConsumer.accept(msg);
        }
    }
    public static void e(String tag, String msg, Throwable tr){
        Log.e(tag, msg, tr);

        LogUtils.file(LogUtils.E,msg,tr);

        if(logConsumer != null){
            logConsumer.accept(msg);
        }
    }
    public static void e(String tag, Throwable tr){
        String msg = tr != null ? tr.getMessage() : "";
        Log.e(tag, msg, tr);

        LogUtils.file(LogUtils.E,msg,tr);
    }
}
